from dataset.build_data import dataloder
from configs.config import _C as config
from model.LayoutLMv2Model import LayoutLMv2Model
from trainer.pretrain import LayoutLMv2Trainer
from dataset.vocab import WordVocab
train_data = dataloder(config)

trainer = LayoutLMv2Trainer(LayoutLMv2Model, config, train_data)
if __name__=="__main__":
    for epoch in range(config.TRAIN.EPOCHS):
        trainer.train(epoch)
        acc = 0
        last_acc = trainer.total_acc
        print("***"*20+"acc",last_acc)
        if acc <last_acc:
            acc = last_acc
            trainer.save(epoch, config.TRAIN.OUTPUT_PATH)
